<?php
// PASOS
// 1 - VOY A CONSOLA Y SETEO PARAMETROS DEL PUERTO SERIE 
// stty -F /dev/ttyS0 cs8 -parenb -cstopb 115200 -- LINUX
// La siguiente línea ejecutará una orden en DOS. Esto solo debe ejecutarse una vez.
// `mode COM1: baud=115200 parity=n data=8 stop=1`; -- WINDOWS

//ENVIAMOS PAQUETE UNICIALIZADOR

$paqueteInicializador = ' "<4^5^00^54.65^|835>" > 
 "<5^1^GI|434>" > 
 "<|>" > 
 "<|>" > 
 "<2^1^0^2^0^3^0^4^0^5^0^6^0^7^0^8^0^9^0^10^0^11^0^12^0^13^0^14^0^15^0|4664>" > 
 "<2^16^0^17^0^18^0^19^0^20^0^21^0^22^0^23^0^24^0^25^0^26^0^27^0^28^0^29^0^30^0|5132>" > 
 "<2^31^0^32^0^33^0^34^0^35^0^36^0^37^0^38^0^39^0^40^0^41^0^42^0^43^0^44^0^45^0|5141>" > 
 "<2^46^0^47^0^48^0^49^0^50^0^51^0^52^0^53^0^54^0^55^0^56^0^57^0^58^0^59^0^60^0|5177>" > 
 "<2^61^0^62^0^63^0^64^0^65^0^66^0^67^0^68^0^69^0^70^0^71^0^72^0^73^0^74^0^75^0|5186>" > 
 "<2^76^0^77^0^78^0^79^0^80^0^81^0^82^0^83^0^84^0^85^0^86^0^87^0^88^0^89^0^90^0|5222>" > 
 "<|>" > 
 "<2^90^0^91^0^92^0^93^0^94^0|1765>" > 
 "<5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85^7^5BCA^8^HOLA^9^10/10/2007^10^14:55:30|5375>" > 
 "<5^11^1^12^0^13^30^14^30^15^Buenos Aires^16^Add1^17^Add2^18^Restricted Ticket^19^Debit Ticket^20^654236|8164>" > 
 "<5^21^123855^22^1^23^00,63,5462^24^0000^25^2^26^1,2,3,4,5,6^27^0.25^28^0.10^29^0.01^30^0|5216>" > 
 "<5^31^0^32^0^33^0^34^-1^35^1^36^1|2132>" > 
 "<11^0.01|2^1^0^2^0^3^0|1415>" > 
 "<11^0.01|2^6^0^7^0^8^0|1430>" > 
 "<11^0.01|2^14^0|894>" > 
 "<11^0.05|2^1^0^2^0^3^0|1419>" > 
 "<11^0.05|2^6^0^7^0^8^0|1434>" > 
 "<11^0.05|2^14^0|898>" > 
 "<11^0.10|2^1^0^2^0^3^0|1415>" > 
 "<11^0.10|2^6^0^7^0^8^0|1430>" > 
 "<11^0.10|2^14^0|894>" > 
 "<11^0.25|2^1^0^2^0^3^0|1421>" > 
 "<11^0.25|2^6^0^7^0^8^0|1436>" > 
 "<11^0.25|2^14^0|900>" > 
 "<11^0.50|2^1^0^2^0^3^0|1419>" > 
 "<11^0.50|2^6^0^7^0^8^0|1434>" > 
 "<11^0.50|2^14^0|898>" > 
 "<11^1.00|2^1^0^2^0^3^0|1415>" > 
 "<11^1.00|2^6^0^7^0^8^0|1430>" > 
 "<11^1.00|2^14^0|894>" > 
 "<11^5.00|2^1^0^2^0^3^0|1419>" > 
 "<11^5.00|2^6^0^7^0^8^0|1434>" > 
 "<11^5.00|2^14^0|898>" > 
 "<11^10.00|2^1^0^2^0^3^0|1463>" > 
 "<11^10.00|2^6^0^7^0^8^0|1478>" > 
 "<11^10.00|2^14^0|942>" > 
 "<11^20.00|2^1^0^2^0^3^0|1464>" > 
 "<|>" > 
 "<11^20.00|2^6^0^7^0^8^0|1479>" > 
 "<11^20.00|2^14^0|943>" > 
 "<11^100.00|2^1^0^2^0^3^0|1511>" > 
 "<11^100.00|2^6^0^7^0^8^0|1526>" > 
 "<11^100.00|2^14^0|990>" > 
 "<11^0.20|2^1^0^2^0^3^0|1416>" > 
 "<11^0.20|2^6^0^7^0^8^0|1431>" > 
 "<11^0.20|2^14^0|895>" > 
 "<11^2.00|2^1^0^2^0^3^0|1416>" > 
 "<11^2.00|2^6^0^7^0^8^0|1431>" > 
 "<11^2.00|2^14^0|895>" > 
 "<11^2.50|2^1^0^2^0^3^0|1421>" > 
 "<11^2.50|2^6^0^7^0^8^0|1436>" > 
 "<11^2.50|2^14^0|900>" > 
 "<11^25.00|2^1^0^2^0^3^0|1469>" > 
 "<11^25.00|2^6^0^7^0^8^0|1484>" > 
 "<11^25.00|2^14^0|948>" > 
 "<11^50.00|2^1^0^2^0^3^0|1467>" > 
 "<11^50.00|2^6^0^7^0^8^0|1482>" > 
 "<11^50.00|2^14^0|946>" > 
 "<11^200.00|2^1^0^2^0^3^0|1512>" > 
 "<11^200.00|2^6^0^7^0^8^0|1527>" > 
 "<11^200.00|2^14^0|991>" > 
 "<11^250.00|2^1^0^2^0^3^0|1517>" > 
 "<11^250.00|2^6^0^7^0^8^0|1532>" > 
 "<11^250.00|2^14^0|996>" > 
 "<11^500.00|2^1^0^2^0^3^0|1515>" > 
 "<11^500.00|2^6^0^7^0^8^0|1530>" > 
 "<11^500.00|2^14^0|994>" > 
 "<11^1000.00|2^1^0^2^0^3^0|1559>" > 
 "<11^1000.00|2^6^0^7^0^8^0|1574>" > 
 "<11^1000.00|2^14^0|1038>" > 
 "<11^2000.00|2^1^0^2^0^3^0|1560>" > 
 "<11^2000.00|2^6^0^7^0^8^0|1575>" > 
 "<11^2000.00|2^14^0|1039>" > 
 "<11^2500.00|2^1^0^2^0^3^0|1565>" > 
 "<11^2500.00|2^6^0^7^0^8^0|1580>" > 
 "<11^2500.00|2^14^0|1044>" > 
 "<11^5000.00|2^1^0^2^0^3^0|1563>" > 
 "<11^5000.00|2^6^0^7^0^8^0|1578>" > 
 "<11^5000.00|2^14^0|1042>" > 
 "<11^0.02|2^1^0^2^0^3^0|1416>" > 
 "<11^0.02|2^6^0^7^0^8^0|1431>" > 
 "<11^0.02|2^14^0|895>" > 
 "<11^0.03|2^1^0^2^0^3^0|1417>" > 
 "<11^0.03|2^6^0^7^0^8^0|1432>" > 
 "<11^0.03|2^14^0|896>" > 
 "<11^0.15|2^1^0^2^0^3^0|1420>" > 
 "<11^0.15|2^6^0^7^0^8^0|1435>" > 
 "<11^0.15|2^14^0|899>" > 
 "<11^0.40|2^1^0^2^0^3^0|1418>" > 
 "<11^0.40|2^6^0^7^0^8^0|1433>" > 
 "<11^0.40|2^14^0|897>" > 
 "<10^1|2^1^0^2^0^3^0^4^0|1560>" > 
 "<10^1|2^6^0^7^0^8^0|1287>" > 
 "<10^1|2^92^0|757>" > 
 "<10^1|2^72^0|755>" > 
 "<10^1|2^14^0|751>" > 
 "<10^1|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3268>" > 
 "<10^1|5^29^0.01|903>" > 
 "<10^1|5^37^0|759>" > 
 "<10^2|2^1^0^2^0^3^0^4^0|1561>" > 
 "<10^2|2^6^0^7^0^8^0|1288>" > 
 "<10^2|2^92^0|758>" > 
 "<10^2|2^72^0|756>" > 
 "<10^2|2^14^0|752>" > 
 "<10^2|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3269>" > 
 "<10^2|5^29^0.01|904>" > 
 "<10^2|5^37^0|760>" > 
 "<10^3|2^1^0^2^0^3^0^4^0|1562>" > 
 "<10^3|2^6^0^7^0^8^0|1289>" > 
 "<10^3|2^92^0|759>" > 
 "<10^3|2^72^0|757>" > 
 "<10^3|2^14^0|753>" > 
 "<10^3|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3270>" > 
 "<10^3|5^29^0.01|905>" > 
 "<10^3|5^37^0|761>" > 
 "<10^4|2^1^0^2^0^3^0^4^0|1563>" > 
 "<10^4|2^6^0^7^0^8^0|1290>" > 
 "<10^4|2^92^0|760>" > 
 "<10^4|2^72^0|758>" > 
 "<10^4|2^14^0|754>" > 
 "<10^4|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3271>" > 
 "<10^4|5^29^0.01|906>" > 
 "<10^4|5^37^0|762>" > 
 "<10^5|2^1^0^2^0^3^0^4^0|1564>" > 
 "<10^5|2^6^0^7^0^8^0|1291>" > 
 "<10^5|2^92^0|761>" > 
 "<10^5|2^72^0|759>" > 
 "<10^5|2^14^0|755>" > 
 "<10^5|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3272>" > 
 "<10^5|5^29^0.01|907>" > 
 "<10^5|5^37^0|763>" > 
 "<10^6|2^1^0^2^0^3^0^4^0|1565>" > 
 "<10^6|2^6^0^7^0^8^0|1292>" > 
 "<10^6|2^92^0|762>" > 
 "<10^6|2^72^0|760>" > 
 "<10^6|2^14^0|756>" > 
 "<10^6|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3273>" > 
 "<10^6|5^29^0.01|908>" > 
 "<10^6|5^37^0|764>" > 
 "<10^7|2^1^0^2^0^3^0^4^0|1566>" > 
 "<10^7|2^6^0^7^0^8^0|1293>" > 
 "<10^7|2^92^0|763>" > 
 "<10^7|2^72^0|761>" > 
 "<10^7|2^14^0|757>" > 
 "<10^7|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3274>" > 
 "<10^7|5^29^0.01|909>" > 
 "<10^7|5^37^0|765>" > 
 "<10^8|2^1^0^2^0^3^0^4^0|1567>" > 
 "<10^8|2^6^0^7^0^8^0|1294>" > 
 "<10^8|2^92^0|764>" > 
 "<10^8|2^72^0|762>" > 
 "<10^8|2^14^0|758>" > 
 "<10^8|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3275>" > 
 "<10^8|5^29^0.01|910>" > 
 "<10^8|5^37^0|766>" > 
 "<10^9|2^1^0^2^0^3^0^4^0|1568>" > 
 "<10^9|2^6^0^7^0^8^0|1295>" > 
 "<10^9|2^92^0|765>" > 
 "<10^9|2^72^0|763>" > 
 "<10^9|2^14^0|759>" > 
 "<10^9|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3276>" > 
 "<10^9|5^29^0.01|911>" > 
 "<10^9|5^37^0|767>" > 
 "<10^10|2^1^0^2^0^3^0^4^0|1608>" > 
 "<10^10|2^6^0^7^0^8^0|1335>" > 
 "<10^10|2^92^0|805>" > 
 "<10^10|2^72^0|803>" > 
 "<10^10|2^14^0|799>" > 
 "<10^10|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3316>" > 
 "<10^10|5^29^0.01|951>" > 
 "<10^10|5^37^0|807>" > 
 "<10^11|2^1^0^2^0^3^0^4^0|1609>" > 
 "<10^11|2^6^0^7^0^8^0|1336>" > 
 "<10^11|2^92^0|806>" > 
 "<10^11|2^72^0|804>" > 
 "<10^11|2^14^0|800>" > 
 "<10^11|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3317>" > 
 "<10^11|5^29^0.01|952>" > 
 "<10^11|5^37^0|808>" > 
 "<10^12|2^1^0^2^0^3^0^4^0|1610>" > 
 "<10^12|2^6^0^7^0^8^0|1337>" > 
 "<10^12|2^92^0|807>" > 
 "<10^12|2^72^0|805>" > 
 "<10^12|2^14^0|801>" > 
 "<10^12|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3318>" > 
 "<10^12|5^29^0.01|953>" > 
 "<10^12|5^37^0|809>" > 
 "<10^13|2^1^0^2^0^3^0^4^0|1611>" > 
 "<10^13|2^6^0^7^0^8^0|1338>" > 
 "<10^13|2^92^0|808>" > 
 "<10^13|2^72^0|806>" > 
 "<10^13|2^14^0|802>" > 
 "<10^13|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3319>" > 
 "<10^13|5^29^0.01|954>" > 
 "<10^13|5^37^0|810>" > 
 "<10^14|2^1^0^2^0^3^0^4^0|1612>" > 
 "<10^14|2^6^0^7^0^8^0|1339>" > 
 "<10^14|2^92^0|809>" > 
 "<10^14|2^72^0|807>" > 
 "<10^14|2^14^0|803>" > 
 "<10^14|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3320>" > 
 "<10^14|5^29^0.01|955>" > 
 "<10^14|5^37^0|811>" > 
 "<10^15|2^1^0^2^0^3^0^4^0|1613>" > 
 "<10^15|2^6^0^7^0^8^0|1340>" > 
 "<10^15|2^92^0|810>" > 
 "<10^15|2^72^0|808>" > 
 "<10^15|2^14^0|804>" > 
 "<10^15|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3321>" > 
 "<10^15|5^29^0.01|956>" > 
 "<10^15|5^37^0|812>" > 
 "<10^16|2^1^0^2^0^3^0^4^0|1614>" > 
 "<10^16|2^6^0^7^0^8^0|1341>" > 
 "<10^16|2^92^0|811>" > 
 "<10^16|2^72^0|809>" > 
 "<10^16|2^14^0|805>" > 
 "<10^16|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3322>" > 
 "<10^16|5^29^0.01|957>" > 
 "<10^16|5^37^0|813>" > 
 "<10^17|2^1^0^2^0^3^0^4^0|1615>" > 
 "<10^17|2^6^0^7^0^8^0|1342>" > 
 "<10^17|2^92^0|812>" > 
 "<10^17|2^72^0|810>" > 
 "<10^17|2^14^0|806>" > 
 "<10^17|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3323>" > 
 "<10^17|5^29^0.01|958>" > 
 "<10^17|5^37^0|814>" > 
 "<10^18|2^1^0^2^0^3^0^4^0|1616>" > 
 "<10^18|2^6^0^7^0^8^0|1343>" > 
 "<10^18|2^92^0|813>" > 
 "<10^18|2^72^0|811>" > 
 "<10^18|2^14^0|807>" > 
 "<10^18|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3324>" > 
 "<10^18|5^29^0.01|959>" > 
 "<10^18|5^37^0|815>" > 
 "<10^19|2^1^0^2^0^3^0^4^0|1617>" > 
 "<10^19|2^6^0^7^0^8^0|1344>" > 
 "<10^19|2^92^0|814>" > 
 "<10^19|2^72^0|812>" > 
 "<10^19|2^14^0|808>" > 
 "<10^19|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3325>" > 
 "<10^19|5^29^0.01|960>" > 
 "<10^19|5^37^0|816>" > 
 "<10^20|2^1^0^2^0^3^0^4^0|1609>" > 
 "<10^20|2^6^0^7^0^8^0|1336>" > 
 "<10^20|2^92^0|806>" > 
 "<10^20|2^72^0|804>" > 
 "<10^20|2^14^0|800>" > 
 "<10^20|5^1^GI^2^H12^3^0.01^4^1000^5^BISONG^6^95.85|3317>" > 
 "<10^20|5^29^0.01|952>" > 
 "<10^20|5^37^0|808>" > 
 "<5^39^777^40^0^41^0^42^0^43^0000000000000000000000000000000000000000^44^-1^45^00^46^00^47^00^48^9999^49^0^50^00^51^0^52^0^53^0^54^0|7904>" > 
 "<2^95^0^96^0^97^0^98^0^99^0^100^0^101^0^102^0^103^0^104^0^105^0^106^0^107^0^108^0^109^0|5645>" > 
 "<2^110^0^111^0^112^0^113^0^114^0^115^0^116^0^117^0^118^0^119^0|3915>" > 
 "<|>" > 
 "<|>" > 
 "<|>" > 
 "<|>" > ';


// "<1^1|192>" >  abrir
// $event = '<1^1|192>';

// //Enviamos por puerto serie los datos
// exec ('echo '.$paqueteInicializador.' > /dev/ttyS0');

include "php_serial.class.php";


// `mode COM1: baud=115200 parity=n data=8 stop=1`;

$serial = new phpSerial();
$serial->deviceSet("/dev/ttyS0"); // aqui cambio el /dev/ttyS0 por COM1 cuando quiero ejecutarlo en windows

// $serial->confBaudRate(115200);
// $serial->confParity("none");
// $serial->confCharacterLength(8);
// $serial->confStopBits(1);
// $serial->confFlowControl("none");


//$serial->deviceSet("COM1");
if ($serial->deviceOpen()){
	echo 'el programa ya se inicio';
}
$var=sprintf($paqueteInicializador);
$serial->sendMessage($var);
// $read = $serial->readPort();
// echo $read;
if ($serial->deviceClose()){
echo 'el programa ya finalizo';
}


?>
